package org.bao.controller;

import com.taobao.api.ApiException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.bao.response.Response;
import org.bao.service.ProcessMsg;
import org.bao.utools.IPutools;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author ：feller
 * @date ：Created in 2022/05/12 17:18
 * @description：接受平台发来的消息
 * @version: 1.0
 */

@RestController
@Api(tags = "接受平台消息")
@RequestMapping(value = "/receiveMsg")
public class ReceiveMsgController {

        private final Logger logger = LoggerFactory.getLogger(ReceiveMsgController.class);

        @Autowired
        private ProcessMsg processMsg;

        @ApiOperation(value = "接受消息" ,notes="接受消息")
        @RequestMapping(value = "/alert", method = RequestMethod.POST)
        public Response alert(@RequestBody String Msg , HttpServletRequest request) throws ApiException {
            String requestIp = IPutools.getIpAddr(request);
            logger.info("请求IP -> {},接受到的消息 -> {}",requestIp,Msg);
            return processMsg.checkMsg(Msg);
        }

}
